package com.cyj.springbootservice.api.entity.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @description:
 * @Author C_Y_J
 * @create 2021/10/7 13:47
 **/
@Getter
public enum Motion {
    // 动作 0:悬停, 	1:自动返航, 	2:原地降落, 	3:返回航线起始点, 	4:继续执行
    HOVER(0, "悬停"),
    AUTOMATIC_RETURN (1, "自动返航"),
    IN_SITU_LANDING(2, "原地降落"),
    RETURN_TO_THE_STARTING_POINT(3, "返回航线起始点"),
    GO_AHEAD(4, "继续执行");

    @JsonValue
    @EnumValue
    private final int code;
    private final String name;

    Motion(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static Motion valueOf(int code) {
        for (Motion item : values()) {
            if (item.getCode() == code) {
                return item;
            }
        }

        return null;
    }

}